﻿using System;

namespace LogikBug.ModularMvc.Caching
{
	public class CacheKey<T> : CacheKeyBase
	{
		private readonly T _item;

		public CacheKey(T value)
		{
			_item = value;
		}

		public static implicit operator CacheKey<T>(T value)
		{
			return new CacheKey<T>(value);
		}

		public static implicit operator T(CacheKey<T> value)
		{
			return value._item;
		}

		public T CachedItem
		{
			get
			{
				LastAccessedDate = DateTime.Now;

				return _item;
			}
		}

		public override Type ItemType
		{
			get
			{
				return typeof(T);
			}
		}
	}
}
